import com.beans.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        //1、先得到上下文对象
        ApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        BeanScope1 beanScope1 = context.getBean(BeanScope1.class);
        User user1 = beanScope1.getUser();
        System.out.println("BeanScope1: " + user1);
        BeanScope2 beanScope2 = context.getBean(BeanScope2.class);
        User user2 = beanScope2.getUser();
        System.out.println("BeanScope2: " + user2);
//        UserController2 userController2 = context.getBean(UserController2.class);
//        userController2.sayHi();
//        UserController4 userController4 = context.getBean(UserController4.class);
//        userController4.sayHi();
//        //2、得到bean
//        UserController controller = context.getBean("userController",UserController.class);
//        //3、启动bean
//        controller.sayHi();
//        UserService service = context.getBean(UserService.class);
//        service.sayHi();
//        UserRepository repository = context.getBean(UserRepository.class);
//        repository.sayHi();
//        UserComponent component = context.getBean(UserComponent.class);
//        component.sayHi();
//        UserConfiguration configuration = context.getBean(UserConfiguration.class);
//        configuration.sayHi();
    }
}
